


public class Main {
    public static void main(String[] args) {
        int[] A = {1,3,5};
        int[] B = {5,7,9};
        int[] s =  ex(A,A.length,B,B.length);
        System.out.println(s.toString());
    }
    public static int[] ex(int[] A, int m, int[] B, int n){
        int i = m-1;
        int j = n-1;
        int k = m+n-1;
        while(i>=0&&j>=0){
            if(A[i]>B[j]){
                A[k--]=A[i--];
            }else{
                A[k--] = B[j--];
            }
        }
        while(i>=0){
            A[k--]=A[i--];
        }
        while(j>=0){
            A[k--] = B[j--];
        }
        return A;
    }

}
